﻿using System;
using WinRTFramework.Common;
using WinRTFramework.Interfaces.Contracts.Sharing;
using Windows.ApplicationModel.DataTransfer;

namespace ShareSource.ViewModels
{
    public class ShareLinkViewModel_Showcase : Bindable, ISupportSharingSourceContract
    {
        public string Title { get; set; }
        public string Description { get; set; }
        public string Uri { get; set; }

        DelegateCommand _shareCommand;
        public DelegateCommand ShareCommand
        {
            get
            {
                return _shareCommand = _shareCommand ?? new DelegateCommand(Share);
            }
        }

        void Share()
        {
            SharingService.ShowShareUI();
        }

        public void OnShareRequested(DataRequest dataRequest)
        {
            dataRequest.Data.Properties.Title = Title;
            dataRequest.Data.Properties.Description = Description; // The description is optional.
            dataRequest.Data.SetUri(new Uri(Uri));
        }

        public ISharingService SharingService
        {
            get;
            set;
        }
    }
}
